# $Id: PKGBUILD 135906 2015-06-26 14:54:21Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Sebastian Wiesner <lunaryorn googlemail com>
# Contributor: Igor Ramos Tiburcio <irtigor@yahoo.com.br>
# Contributor: Wieland Hoffmann <themineo+aur@gmail.com>
# Contributor: Hervé Cauwelier <herve ¤ oursours.net>
# Contributor: Felix Kaiser <felix.kaiser@fxkr.net>

pkgbase=python-py
pkgname=('python3-py' 'python2-py')
pkgver=1.8.0
pkgrel=1
pkgdesc="library with cross-python path, ini-parsing, io, code, log facilities"
arch=('any')
license=('MIT')
url="https://pylib.readthedocs.io/"
makedepends=('python3-setuptools'
             'python3-setuptools-scm'
             'python2-setuptools'
             'python2-setuptools-scm')
source=("https://pypi.python.org/packages/source/p/py/py-${pkgver}.tar.gz")
sha512sums=('83c7de6cfe89f5064f5f7266739b16adf61fd8f4f77ead787e17e41b7fb4d5f68fa242eab9a04c0c1a88cc7c47e68c78256e4432c5f8eeff5ac3dc36a90cfa3a')

prepare() {
  cp -a py-${pkgver}{,-py2}
  export LC_CTYPE=en_US.UTF-8
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "$srcdir/py-${pkgver}"
  /usr/bin/python3 setup.py build

  cd "$srcdir/py-${pkgver}-py2"
  /usr/bin/python2 setup.py build
}

package_python3-py() {
  depends=('python3')

  cd py-${pkgver}
  /usr/bin/python3 setup.py install --root="${pkgdir}" --optimize=1
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

package_python2-py() {
  depends=('python2')

  cd py-${pkgver}-py2
  /usr/bin/python2 setup.py install --root="${pkgdir}" --optimize=1
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

